<!--下拉框-->
<template>
    <div>
        <el-select v-model="stair[second]" @change="geijkjse" filterable>
            <el-option :label="sd.desc" :value="sd.value" v-for="(sd,idx) in list" :key="idx"></el-option>
        </el-select>
    </div>
</template>
<script>
    export default {
        props: {
            label: {
                title: '显示的名称',
                type: String,
                required: true
            },
            urls: {
                title: '接口请求路径',
                type: String,
                required: true
            },
            parameter: {
                title: '接口请求参数',
                type: Object,
                default: function() {
                    return {}
                }
            },
            stair: {
                title: '父组件查询的json',
                type: Object,
                required: true
            },
            second: {
                title: '父组件里定义的json参数',
                type: String,
                required: true
            }

        },
        data() {
            return {
                list: [],
                values: ''
            }
        },
        components: {},
        methods: {
            async getlist() {
                let res = await this.zhycget(this.urls, this.parameter)
                this.list = res.obj
            },
            geijkjse(e) {
                this.stair[this.second] = e
                this.$emit('callBack', e)
            },
            qingkong() {
                this.values = ''
            }
        },
        computed: {
            ownerCode() {
                return this.$store.state.ownerCode;
            }
        },
        mounted() {
            // 如果为二级下拉框就不初始值
            if (!this.parameter.SecondLevel) {
                this.getlist()
            }

        },
        watch: {
            ownerCode: {
                handler: function() {
                    if (this.parameter.SecondLevel) {
                        this.parameter.ownerCode = this.ownerCode
                        this.getlist()
                    }
                },
                deep: true
            }
        }
    }

</script>
<style scoped>

</style>
